<template lang="pug">
  v-form(direction="vertical" style="width:400px")
    v-form-item(label="名称")
        v-input(type="text" placeholder="系统名称" size="large" v-model="formData.system_name")
    v-form-item(label="系统域名" required)
        v-input(type="text" placeholder="系统域名" size="large" v-model="formData.system_domain")
    v-form-item(label="系统路径" required)
        v-input(type="text" placeholder="系统路径" size="large" v-model="formData.system_path")
    v-form-item(label="选择节点")
      v-select(v-model="formData.system_nodes" placeholder="请选择节点" notfound="无法找到" :data="nodeslist" :multiple="true")
    v-form-item(style="margin-top:24px")
        v-button( type="primary" html-type="button" @click="submitForm") 确定
</template>
<script>
export default {
  name: 'systems-create',
  data () {
    return {
      nodeslist: [{label: '默认节点', value: '127.0.0.1'}, {label: '默认节点2', value: '127.0.0.1'}],
      formData: {
        system_name: '',
        system_domain: 'https://siwi.me',
        system_path: '/data/nodejs/www',
        system_nodes: []
      }
    }
  },
  methods: {
    submitForm () {
      this.$http.post('rbac/system', this.formData)
        .then(res => {
          let result = res.data
          if (result.ret === 0) {
            this.$message.info(result.msg)
            this.$router.push({
              name: 'SystemsList'
            })
          } else {
            this.$message.info(result.msg)
          }
        })
    }
  }
}
</script>
